package com.jkl.controller.drTemplate;


import javax.servlet.http.HttpServletRequest;

import com.jkl.entity.drTemplate.DrTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jkl.entity.BaseResponseDTO;
import com.jkl.service.drTemplate.inter.DrTemplateServiceInterface;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/jky/drTemplate")
@Slf4j
public class DrTemplateController {

	@Autowired
	private HttpServletRequest request;

	@Autowired
	private DrTemplateServiceInterface DrTemplateServiceInterface;
	
	@PostMapping("/getTemplateList")
	public PageInfo<DrTemplate> getIndexList(@RequestBody  DrTemplate drTemplate) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		PageInfo<DrTemplate> drIndexList = DrTemplateServiceInterface.selectTableId(drTemplate);
		return drIndexList;

	}
	@PostMapping("/saveTemplate")
	public BaseResponseDTO save(@RequestBody DrTemplate drTemplate) {
		drTemplate.setStatus("1");
		BaseResponseDTO returnData = new BaseResponseDTO();
		int drIndexInt = DrTemplateServiceInterface.save(drTemplate);
		if(drIndexInt!=0) {
			returnData.setResultMessage("添加成功");
		}else {
			returnData.setResultMessage("添加失败");
		}
		
		return returnData;

	}
	@PutMapping("/upDateTemplate")
	public BaseResponseDTO upDate(@RequestBody DrTemplate drTemplate) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		int drIndexInt = DrTemplateServiceInterface.updateDrindex(drTemplate);
		if(drIndexInt!=0) {
			returnData.setResultMessage("修改成功");
		}else {
			returnData.setResultMessage("修改失败");
		}
		
		return returnData;

	}
	
	
	
	
	
}
